/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 徐海涛
 * Date: 2021-11-24
 * Time: 22:44
 * 题目：1,2,3
 * 编写一个类Calculator,有两个属性num1,num2,这两个数据的值，
 * 不能在定义的同时初始化，最后实现加减乘(main1)
 * 2
 * 3
 * 实现交换两个变量的值。要求：需要交换实参的值(main3)
 *
 */
class Calculator {
   private int num1;
   private int num2;
    public int getNum2() {
        return num2;
    }
    public void setNum2(int num2) {
        this.num2 = num2;
    }
    public int getNum1() {
        return num1;
    }
    public void setNum1(int num1) {
        this.num1 = num1;
    }
    public int sdd() {
        return num1 + num2;
    }
    public int sub() {
        return num1 - num2;
    }
    public int mul() {
        return num1*num2;
    }
    public double div() {
        return num1*1.0/num2;
    }
}
class  Fest {
    public int age;//字段，属性，成员变量。
}
public class TestClass {
    public static void main(String[] args) {
        Calculator calculator = new Calculator();
        calculator.setNum2(20);
        calculator.setNum1(10);
        System.out.println(calculator.getNum2());
        System.out.println(calculator.sub());
        System.out.println(calculator.mul());
        System.out.println(calculator.div());
    }















    public static void swap(Fest fest1, Fest fest2) {
        int tmp = fest1.age;
        fest1.age = fest2.age;
        fest2.age = tmp;
    }

    public static void main3(String[] args) {
        Fest fest1 = new Fest();//交换实参的值
        fest1.age = 10;
        System.out.println(fest1.age);
        Fest fest2 = new Fest();
        fest2.age = 20;
        System.out.println(fest2.age);
        swap(fest1, fest2);//调用swap里的fest的值
        System.out.print(fest1.age + " " + fest2.age);
    }
}

